<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var arr = new Array(5);
        arr[1] = 2
        arr[3] = 4
        console.log(arr)
        
        for(var key of arr){
            console.log(key)
        }
        
        // var arr1 = []
        // for(var key in arr){
        //     arr1.push(arr[key])
        // }
        // console.log(arr1)
        
        var arr2 = arr.filter(
            function(value,index){
                return value != undefined
            }
        )
        console.log(arr2)
    </script>
</body>
</html>